window.onload = function  () {
 	imglist = document.getElementsByTagName('img')
 	banner = document.getElementById('banner')
 	click_list = document.getElementsByTagName("li")
 	click_right = document.getElementById('click_right')
 	click_left = document.getElementById('click_left')
 	num=0
 	function run () {
 		
 		for (var x=0 ;x<imglist.length ;x++) {
 			imglist[x].style.display="none";
 			click_list[x].style.backgroundColor= "#6b6b6b";
 		};

 		imglist[num].style.display="block";
 		click_list[num].style.backgroundColor= "#fff";

 		if (num==imglist.length-1) {
 			num=0;
 		}else{
 			num++;
 		}
 		
 	}
 	time = setInterval(run, 1000)
 	banner.onmouseover = function  () {
 		clearInterval(time)
 	}
 	banner.onmouseout = function  () {
 		time = setInterval(run, 1000)
 	}


 	


/////多个点击事件用for和function  
 	for (var z = 0; z < click_list.length; z++) {
		add_list(z);
	};

	function add_list (xy) {
		click_list[xy].onclick = function  () {
			num = xy;
			run();
		}
	}

	click_right.onclick = function  () {
		run();
	}

	click_left.onclick = function  () {
		// alert(num)
		if (num==1) {
			num=click_list.length-1;
		}else if (num==0) {
			num=click_list.length-2;

		}else{
			num-=2;
		}
			
			run()
		
	}




}

